package javaAdvanced;

/**
 * @author cuiH
 * Date: 13-11-8
 */
public class FinallyTest {
    /*
    * finally 必须在进入try块之后才执行，而且一定会执行
    * */
    public static void main(String[] args) {
        int test = 0;  //初始化资源
        try{
            test++;
//            if(test == 2) throw new Exception();           //不进去catch的情况 输出：5  说明finanlly都执行
            if(test == 1) throw new Exception();           //进去catch块的情况 输出：1，5
        }catch(Exception e){
            System.out.println(test);
            int testInner = 0;  //初始化资源
            try{
                testInner++;
                if(testInner == 1) throw new Exception();           //进去catch块的情况 输出：1，5
            }catch(Exception e2){
                System.out.println(testInner);
            }finally {
                testInner =10;
                System.out.println(10);
            }
        }finally {
            test =5;
        }
        System.out.println(test);
    }
}
